package com.me.mvc.controller;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import com.me.mvc.model.ModelUtils;

import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.support.RequestContextUtils;

@Controller
@RequestMapping("/")
public class Home {
	@RequestMapping(method = RequestMethod.GET)
	public String printWelcome(ModelMap model) {
		model.addAttribute("message", "Hello world!");
		return "index";
	}
	@RequestMapping(value = "index", method = RequestMethod.GET)
	public String printWelcome1(ModelMap model, HttpServletRequest request) {
		model.addAttribute("message", "Hello world!");
		ModelUtils.initFromSource();

        Locale locale = RequestContextUtils.getLocale(request);
        String country = locale.getCountry();
        String language = locale.getLanguage();

        Locale locale1 = LocaleContextHolder.getLocale();
        String country1 = locale.getCountry();
        String language1 = locale.getLanguage();

		return "index";
	}
}